//
//  LBCardQuanCell.m
//  V-Learn
//
//  Created by Apple on 2019/1/18.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "LBCardQuanCell.h"

@interface LBCardQuanCell ()

@property (weak, nonatomic) IBOutlet UIImageView *bgIcon;

@end
@implementation LBCardQuanCell
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identiffer = @"LBCardQuanCell";
    LBCardQuanCell *cell = [tableView dequeueReusableCellWithIdentifier:identiffer];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"LBCardQuanCell" owner:nil options:nil] firstObject];
        
    }
    return cell;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.contentView.backgroundColor = rgb(242,242,242);
    
    //通用
    self.tongyongLab = [UILabel labelWithText:@"通用型代金券" andTextColor:[UIColor whiteColor] andName:nil andFontSize:15*kScaleFit];
    
    [self.bgIcon addSubview:self.tongyongLab];
    [self.tongyongLab makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20*kScaleFit);
        make.left.mas_equalTo(33*kScaleFit);
        
    }];
    
    //时间
    self.timeLab = [UILabel labelWithText:@"有效期：2018.12.16-2019.12-15" andTextColor:rgb(178,178,178) andName:nil andFontSize:13*kScaleFit];
    
    [self.bgIcon addSubview:self.timeLab];
    [self.timeLab makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-30*kScaleFit);
        make.left.mas_equalTo(29*kScaleFit);
        
    }];
    
    //价格
    self.priceLab = [UILabel labelWithText:@"25" andTextColor:rgb(255,255,255) andName:nil andFontSize:28*kScaleFit];
    
    [self.bgIcon addSubview:self.priceLab];
    [self.priceLab makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-29*kScaleFit);
//        make.top.mas_equalTo(23*kScaleFit);
        make.centerY.mas_equalTo(self.tongyongLab);
        
    }];
    
    //价格符号
    self.priceLab2 = [UILabel labelWithText:@"¥" andTextColor:rgb(255,255,255) andName:nil andFontSize:19*kScaleFit];
    
    [self.bgIcon addSubview:self.priceLab2];
    [self.priceLab2 makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.priceLab.mas_left).mas_equalTo(2*kScaleFit);
        make.bottom.mas_equalTo(self.priceLab.mas_bottom);
        
    }];
    
    
    
}
- (void)setModel:(LBCardquanModel *)model{
    _model = model;
    self.priceLab.text = model.voucherPrice;
    NSString *start = [model.voucherStartTime substringToIndex:10];
    NSString *end = [model.voucherEndTime substringToIndex:10];
    NSString *totalTime = [NSString stringWithFormat:@"%@-%@",start,end];
    self.timeLab.text = totalTime;
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
